performs a linear transformation on the original data values.
Suppose that minX
and maxX
are the minimum and maximum of feature X.
We would like to map interval [minX, maxX]
into a new interval
[new_minX, new_maxX]
. Consequently, every value v
from the original
interval will be mapped into value new_v
following formula:
new_v = (v - minX) / (maxX - minX) * (new_maxX - new_minX) + new_minX
If new_minX
and new_maxX
are not given values are mapped
to [0,1]
interval
References:
Hann, J., Kamber, M. (2000). Data Mining: Concepts and Techniques.
Morgan Kaufman Publishers.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(grid_real), | intent(in) | :: | gridIn | |||
type(grid_real), | intent(inout) | :: | gridOut | |||
real(kind=float), | intent(in), | optional | :: | min | ||
real(kind=float), | intent(in), | optional | :: | max |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer(kind=short), | public | :: | i | ||||
integer(kind=short), | public | :: | j | ||||
real(kind=float), | public | :: | new_max | ||||
real(kind=float), | public | :: | new_min | ||||
real(kind=float), | public | :: | old_max | ||||
real(kind=float), | public | :: | old_min |
SUBROUTINE MinMaxNormalizationFloat & ! (gridIn, gridOut, min, max) IMPLICIT NONE !Arguments with intent(in): TYPE (grid_real), INTENT(IN) :: gridIn REAL (KIND = float), OPTIONAL, INTENT(IN) :: min REAL (KIND = float), OPTIONAL, INTENT(IN) :: max !Arguments with intent(inout): TYPE (grid_real), INTENT(INOUT) :: gridOut !Local declaration INTEGER (KIND = short) :: i, j REAL (KIND = float) :: old_min, old_max REAL (KIND = float) :: new_min, new_max !---------------------end of declarations-------------------------------------- !set new_min and new_max IF (PRESENT(min)) THEN new_min = min ELSE new_min = 0. END IF IF (PRESENT(max)) THEN new_max = max ELSE new_max = 0. END IF !get min and max of gridIn old_min = GetMin (gridIn) old_max = GetMax (gridIn) !normalize grid. gridout is supposed to be initialized outside the subroutine DO i = 1, gridIn % idim DO j = 1, gridOut % jdim IF (gridIn % mat (i,j) /= gridIn % nodata) THEN gridOut % mat (i,j) = (gridIn % mat (i,j) - old_min) / & (old_max - old_min) * (new_max - new_min) + new_min END IF END DO END DO RETURN END SUBROUTINE MinMaxNormalizationFloat